<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">
        
    </ui:define>

    <ui:define name="left">
       
    </ui:define>

    <ui:define name="right">
       
    </ui:define>

    <ui:define name="content">
        <style>
            .ui-state-highlight.ui-selected {
                color: blueviolet;
            }
        </style>
        <p:panel style="height: 250px">        
            <h:form id="viewPOForm" style="font-size: 85%">

                <p:messages />

                <h:panelGrid columns="3" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Enter PO Number: "/>
                    <p:inputText value="#{rmpoManagerBean.selectRmpo.poNum}" disabled="true" required="true" requiredMessage="Purchse order number required"/>
                    <p:commandButton update="viewPOForm" oncomplete="poDialog.show();" image="ui-icon ui-icon-search" />    
                </h:panelGrid>
                <p:commandButton value="Next" action="#{rmpoManagerBean.viewPurchaseOrderDisplay()}"/>

            </h:form>
        </p:panel>
        
        <p:dialog header="Search Purchase Order" widgetVar="poDialog" hideEffect="explode" height="600" width="800">
            <h:form id="poForm">
                <p:dataTable var="purchaseOrder" value="#{rmpoManagerBean.allPurchaseOrder}"
                             emptyMessage="No Purchase Orders found with given criteria" selection="#{rmpoManagerBean.selectRmpo}" selectionMode="single" widgetVar="potbl">

                    <p:column filterBy="#{purchaseOrder.poNum}" 
                              headerText="PO Number"
                              filterMatchMode="contains">
                        <h:outputText value="#{purchaseOrder.poNum}" />
                    </p:column>

                    <p:column filterBy="#{purchaseOrder.supplier.supplierName}" 
                              headerText="Supplier Name"
                              filterMatchMode="contains">
                        <h:outputText value="#{purchaseOrder.supplier.supplierName}" />
                    </p:column>
                    
                    <p:column filterBy="#{purchaseOrder.poDate}" 
                              headerText="Date"
                              filterMatchMode="contains">
                        <h:outputText value="#{purchaseOrder.poDate}">
                            <f:convertDateTime pattern="MMMM dd, yyyy"/>
                        </h:outputText>
                    </p:column>

                </p:dataTable>
                <p:commandButton value="Select Purchase Order" update="viewPOForm" oncomplete="poDialog.hide()"/>
            </h:form>
        </p:dialog>
    </ui:define>

    <ui:define name="bottom">
       
    </ui:define>

</ui:composition>
